import { CookieOperator } from '@/common/infrastructure/cookie_operator.js'
import { clear as sessionStorageClear, SessionStorageOperator } from '@/common/infrastructure/session_storage_operator.js'
import { clear as localStorageClear, LocalStorageOperator } from '@/common/infrastructure/local_storage_operator.js'

import { demoCounterStore } from '@/common/storage/pinia/demo_counter';
import { keepAliveStore } from '@/common/storage/pinia/keep_alive';
import { loginInfoStore } from "@/common/storage/pinia/login_info";

// Session 仓储
class SessionStorageMediator {
    public demo:SessionStorageOperator<string> = new SessionStorageOperator<string>('demo')
    public clear = sessionStorageClear
}

// Local 仓储
class LocalStorageMediator {
    public demo:LocalStorageOperator<string> = new LocalStorageOperator<string>('demo')
    public clear = localStorageClear
}

// Pinia 仓储
class PiniaStorageMediator {
    public demo = demoCounterStore()
    public keepAlive = keepAliveStore()
    public loginInfo = loginInfoStore()
}

// 仓储中介者
export class StorageMediator {
    public cookie:CookieOperator = new CookieOperator()
    public session:SessionStorageMediator = new SessionStorageMediator()
    public local:LocalStorageMediator = new LocalStorageMediator()
    public pinia:PiniaStorageMediator = new PiniaStorageMediator()
}